<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

    <script src="Vue/Vue.js"></script>
    <script src="Vue/axios.js"></script>
    <style type="text/css">

        body {
            background-image: url("img/choose.jpg");
            background-repeat: no-repeat;
            background-size: 100%;
        }

        a {
            text-decoration: none;
            font-size: 30px;
            color: white;
        }

        .flo {
            height: 80px;
            width: 260px;
            background-color: rgba(0, 247, 222, 0.4);
            border: 1px solid #00F7DE;
            float: left;
            margin: 60px;
            margin-top: 300px;
            text-align: center;
            line-height: 80px;
            border-radius: 15px;

        }

        .first {
            margin-left: 228px;
        }


    </style>
</head>

<body>
<div id="app">
    <div class="first flo"><a href="instructor/xingqilin/index.html">任课老师模块</a></div>
    <div @click="isMaster" class="flo"><a href="javascript:void(0)" >班主任模块</a></div>
    <div @click="isGrade" class="flo"><a href="javascript:void(0)" >年级主任模块</a></div>
</div>

<script>
    var storage = window.localStorage;
    var token = storage.getItem("token");
    var refreshToken = storage.getItem("refreshToken");



    new Vue({
        el: "#app",
        methods: {
            isMaster: function () {

                axios.post(
                    "/auth/hasRole/" + refreshToken + "/master", {
                        headers: {
                            "token": token,
                            "refreshToken": refreshToken
                        }
                    }
                ).then(res => {
                    if (res.data.code == 500) {
                        console.log("你没有权限")
                        $("#app").html("无权限访问")
                    } else if (res.data.code == 302) {
                        window.parent.location.href = "login.html";
                    } else {
                        console.log(res.data)
                        if(res.data){
                            window.location.href = "classteacher/index.html";
                        }else{
                            alert("你没有权限")
                        }

                    }

                })

            },
            isGrade: function () {

                axios.post(
                    "/auth/hasRole/" + refreshToken + "/grade", {
                        headers: {
                            "token": token,
                            "refreshToken": refreshToken
                        }
                    }
                ).then(res => {
                    if (res.data.code == 500) {
                        console.log("你没有权限")
                        $("#app").html("无权限访问")
                    } else if (res.data.code == 302) {
                        window.parent.location.href = "login.html";
                    } else {
                        console.log(res.data)
                        if(res.data){
                            window.location.href = "1";
                        }else{
                            alert("你没有权限")
                        }

                    }

                })

            }
        }
    })


</script>

</body>
</html>
